package com.IOFileTest;

import org.junit.Test;

import java.io.File;
import java.io.IOException;

public class FileCreate {
    public static void main(String[] args) {

    }
    //练习测试1
    @Test
    public void create01(){
        String filePath = "d:\\new1.txt";
        File file = new File(filePath);
        try {
            file.createNewFile();
            System.out.println("文件创建成功");
        }catch(IOException e){
            e.printStackTrace();
        }
    }

    //练习测试2
    @Test
    public void create02(){
        String fileName = "new2.doc";
        File file = new File("d:\\");
        File file2 = new File(file, fileName);
        try {
            file2.createNewFile();
            System.out.println("创建成功");
        }catch (IOException e){
            e.printStackTrace();
        }

    }

    @Test
    public void create03(){
        String fileName = "new3.ppt";
        String filePath = "d://";
        File file = new File(filePath, fileName);
        try{
            file.createNewFile();
            System.out.println("ppt创建成功");
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
